package com.lanyou.esb.cook.proxy.redis.proxy.impl;

import java.util.HashMap;
import java.util.Map;

import com.lanyou.esb.cook.proxy.common.Constants;
import com.lanyou.esb.cook.proxy.common.Constants4Redis;
import com.lanyou.esb.cook.proxy.entity.Http;
import com.lanyou.esb.cook.proxy.redis.proxy.base.BaseHashJedisProxy;

/**
 * Http接口Redis操作代理
 * 
 * @author Davey.wu
 */
public class HttpJedisProxy extends BaseHashJedisProxy<Http> {

	public HttpJedisProxy() {
		this.setKey(Constants4Redis.REDIS_HASH_KEY_HTTP);
		/** field的组成：系统编码，接口编码，接口版本 **/
		Map<String, Integer> keyFields = new HashMap<>();
		keyFields.put(Constants.SYSTEM_CODE, 0);
		keyFields.put(Constants.INTERFACE_CODE, 1);
		keyFields.put(Constants.INTERFACE_VERSION, 2);
		this.setFields(keyFields);
	}

	@Override
	public Map<String, String> getKeyMap(Http value) {
		Map<String, String> map = new HashMap<>(4);
		map.put(Constants.SYSTEM_CODE, value.getSystemCode());
		map.put(Constants.INTERFACE_CODE, value.getCode());
		map.put(Constants.INTERFACE_VERSION, value.getVersion());
		return map;
	}
}
